package com.analyse.stock.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.analyse.stock.mapper.StrategyPoolMapper;
import com.analyse.stock.model.StrategyPoolModel;
import com.analyse.stock.service.IStrategyPoolService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class StrategyPoolServiceImpl extends ServiceImpl<StrategyPoolMapper, StrategyPoolModel> implements IStrategyPoolService {

    @Override
    public StrategyPoolModel getStrategyPoolByCode(String strategyCode) {
        LambdaQueryWrapper<StrategyPoolModel> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(StrategyPoolModel::getStrategyCode,strategyCode);
        List<StrategyPoolModel> models = super.list(wrapper);
        if(CollUtil.isEmpty(models)){
            return null;
        }
        return models.get(0);
    }
}
